package com.qf.flash.adapter;

import android.view.View;
import android.widget.ImageView;

import com.ctetin.expandabletextviewlibrary.ExpandableTextView;
import com.qf.flash.R;
import com.qf.flash.model.LifeFunBean;
import com.qf.flash.ui.circle.FunDetailsActivity;
import com.qf.flash.utils.ImageLoader;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;


public class FunnyAdapter extends BaseRViewItem<Object> {

    @Override
    public boolean isItemView(Object entity, int position) {
        return entity instanceof LifeFunBean;
    }


    @Override
    public int getItemLayout() {
        return R.layout.item_funny;
    }

    @Override
    public void convert(RViewHolder holder, Object entity, int position, int itemSize) {
        LifeFunBean funBean = (LifeFunBean) entity;
        ImageView ivHead = holder.getView(R.id.iv_head);
        ImageLoader.loadCircle(holder.getmConvertView().getContext(), funBean.getPhoto(), ivHead);
        holder.setText(R.id.tv_name, funBean.getUserName());
        holder.setText(R.id.tv_day, funBean.getShowTime());

        ExpandableTextView expandableTextView = holder.getView(R.id.tv_item);
        expandableTextView.setContent(new ViewModelWithFlag(funBean.getContent()).getTitle().replace("\r\n\r\n", "\n"));
        if (funBean.getSex().equals("1")) {
            holder.setImageResource(R.id.sex, R.mipmap.icon_man);
        } else if (funBean.getSex().equals("2")) {
            holder.setImageResource(R.id.sex, R.mipmap.icon_woman);
        }

        holder.getmConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                FunDetailsActivity.start(holder.getmConvertView().getContext(),funBean.getId(),funBean.getType());
            }
        });
    }
}
